import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'

// https://vitejs.dev/config/
export default defineConfig({
  base: '/h5/',

  plugins: [
    uni(),
    AutoImport({
      imports: ['vue'],
    }),
  ],

  resolve: {
    alias: [
      // { find: '@', replacement: path.resolve(__dirname, './src') },
    ],
  },

  css: {
    // 指定传递给 CSS 预处理器的选项
    preprocessorOptions: {
      scss: {
        // additionalData: `@import '@/styles/variable.scss';`,
      },
    },
    postcss: {
      plugins: [
        require('postcss-px-to-viewport')({
          unitToConvert: 'px',
          viewportWidth: 50,
          unitPrecision: 5,
          ropList: ['*'],
          viewportUnit: 'rpx',
          fontViewportUnit: 'rpx',
          selectorBlackList: [],
          minPixelValue: 0,
          mediaQuery: false,
          replace: true,
          exclude: undefined,
          include: undefined,
          landscape: false,
          landscapeUnit: 'rpx',
          landscapeWidth: 568,
        }),
      ],
    },
  },
})
